package com.zjl.redis.第06章_SpringBoot整合redis;

import redis.clients.jedis.*;


public class B1_Jedis {

    public static Jedis jedis = null;
    public static Jedis getRedis() {
        if(jedis == null){

            DefaultJedisClientConfig.Builder builder = DefaultJedisClientConfig.builder();//创建一个设置参数的类

            JedisClientConfig redisConfig = builder.password("er485g96er8").build();//设置密码方式2

            jedis = new Jedis("82.157.71.243", 6379, redisConfig);//连接Redis

            jedis.auth("er485g96er8");//设置密码方式1
        }
        return jedis;
    }

    public static void main(String[] args) {
        Jedis jedis1 = getRedis();
        System.out.println(jedis1.ping());
        System.out.println(jedis1.get("k1"));
        jedis1.close();
    }

}
